import ReactDom from "react-dom";

import "antd/dist/antd.min.css";

// 1 引入
import React, { useEffect, useState } from "react";

function App() {
  const [count, setCount] = useState(0);
  const [msg, setMsg] = useState("");

  useEffect(() => {
    console.log("我被执行了  ----->  ");
    document.title = count + msg;
  }, [count, msg]); // [依赖项] 🔔 类似vue中的侦听器，开了immediately

  return (
    <div>
      msg -- {msg}
      <hr />
      count -- {count}
      <hr />
      <button onClick={() => setMsg(msg + "~")}>点我修改msg</button>
      <button onClick={() => setCount(count + 1)}>点我修改count</button>
    </div>
  );
}

ReactDom.render(<App />, document.querySelector("#root"));
